#include "gen_lexer_and_parser.hpp"

using namespace std;

static string parser_cmd(int argc, char *args[]);

int main(int argc, char *args[]) {
    string tablePath = parser_cmd(argc, args);
    generateLexerAndParser(args[1], args[2], args[3], tablePath);
    system("pause");
    return 0;
}

static string parser_cmd(int argc, char *args[]){
    string header = "* Zeege (R) Grammar Parser Generator Version 1.0.0\n"
                    "* Copyright(C) Zeege. All rights reserved.\n";
    string asteroids =
        "\n*************************************************************\n";
    cout << asteroids << header << "* Welcome to MyParse! Happy parsing! >_<" << asteroids
         << "\n\n";
    string promptStr = "Invalid arguments.\nUsage: parser_main.exe {lex definition filepath} "
                       "{syntax definition filepath} "
                       "{generated code output dir} "
                       "[parse table output filepath]\n"
                       "e.g. parser_main.exe abc_lex.json abc_syntax.csv ./abclexer ./abclexer/parseTable.csv\n";
    if (argc == 4) {
        return "";
    } else if(argc == 5){
        return args[4];
    } else {
        cout << promptStr << endl;
        system("pause");
        exit(0);
    }
}
